from django.db import models
from user.models import User
from goods.models import Goods
# Create your models here.


class Order(models.Model):
    order_id = models.CharField(max_length=255, verbose_name='订单号')
    total_price = models.CharField(max_length=255, verbose_name='订单总价', default=0)
    status = models.CharField(max_length=255, verbose_name='订单状态', choices=((0, '待支付'), (1, '已支付'), (2, '已取消')), default=0)
    pay_type = models.CharField(max_length=255, verbose_name='支付类型', choices=((0, '支付宝'), (1, '微信')), default=0)
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id')

    class Meta:
        db_table = 'order'


class Cart(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id')
    goods = models.ForeignKey(Goods, on_delete=models.CASCADE, verbose_name='商品id')
    num = models.IntegerField(verbose_name='商品数量', default=1)
    is_show = models.BooleanField(default=True, verbose_name='是否展示')
    is_select = models.BooleanField(default=True, verbose_name='是否选中')

    class Meta:
        db_table = 'cart'


class OrderDeta(models.Model):
    order = models.ForeignKey(Order, on_delete=models.CASCADE, verbose_name='订单号')
    goods_id = models.CharField(max_length=100, verbose_name='商品id')
    goods_price = models.CharField(max_length=100, verbose_name='商品价格')
    goods_img = models.CharField(max_length=200, verbose_name='商品图片')
    goods_name = models.CharField(max_length=100, verbose_name='商品名称')

    class Meta:
        db_table = 'order_deta'

